* Table 4: Gender Gaps and the Inverse of Competitiveness: Additional Factors

clear all 
use Clean_data, clear

***********************T4.GENDER_GAPS_ADDITIONAL_FACTORS*************

*Prep vbles*
 
*Prop. female**
bys year: egen total_id= count(degree) if degree=="M"
bys year: egen female_total=count (degree) if degree=="M" & female==1
bys year: gen prop_female_aux=female_total/total_id if degree=="M"
bys year: egen prop_female=max(prop_female_aux)

*Prop. foreign**
bys year: egen foreign_total=count (degree) if degree=="M" & foreign==1
bys year: gen prop_foreign_aux=foreign_total/total_id if degree=="M"
bys year: egen prop_foreign=max(prop_foreign_aux)

*Unemployment*
*Data obtained from: World Bank Group Data: https://data.worldbank.org/indicator/SL.UEM.TOTL.NE.ZS?end=2023&locations=ES&start=1983 
gen unemployment=.
replace unemployment =18 if year==1983
replace unemployment =21 if year==1984
replace unemployment =21 if year==1985
replace unemployment =20 if year==1986
replace unemployment =19 if year==1987
replace unemployment =18 if year==1988
replace unemployment =16 if year==1989
replace unemployment =16 if year==1990
replace unemployment =16 if year==1991
replace unemployment =20 if year==1992
replace unemployment =23 if year==1993
replace unemployment =23 if year==1994
replace unemployment =22 if year==1995
replace unemployment =21 if year==1996
replace unemployment =20 if year==1997
replace unemployment =18 if year==1998
replace unemployment =15 if year==1999
replace unemployment =13 if year==2000
replace unemployment =10 if year==2001
replace unemployment =11 if year==2002
replace unemployment =11 if year==2003
replace unemployment =10 if year==2004
replace unemployment =8 if year==2005
replace unemployment =8 if year==2006
replace unemployment =8 if year==2007
replace unemployment =13 if year==2008
replace unemployment =18 if year==2009
replace unemployment =20 if year==2010
replace unemployment =22 if year==2011
replace unemployment =25 if year==2012
replace unemployment =25 if year==2013
replace unemployment =23 if year==2014
replace unemployment =20 if year==2015
replace unemployment =18 if year==2016
replace unemployment =16 if year==2017
replace unemployment =14 if year==2018
replace unemployment =13 if year==2019


*Dropout*
reg dropout i.year i.female##c.inv_competNOQUOTA z_GPA i.female##c.prop_female  i.female##c.prop_foreign i.female##c.unemployment if degree=="M"  & z_GPA!=. & foreign==0, robust

*Z_answered, z_Test_Correct, 
global test_ z_answered z_test_correct 

foreach x in $test_ {
reg `x' i.year i.female##c.inv_competNOQUOTA z_GPA i.female##c.prop_female  i.female##c.prop_foreign i.female##c.unemployment if degree=="M" & test==1 & (year<1987 | year>1988) & z_GPA!=. & foreign==0 , robust
}

global notest_ z_test_points z_total_points position

foreach x in $notest_ {
reg `x' i.year i.female##c.inv_competNOQUOTA z_GPA i.female##c.prop_female  i.female##c.prop_foreign i.female##c.unemployment if degree=="M" & test==1  & z_GPA!=. & foreign==0, robust
}

